package com.yhb.third.leshua;


import com.yhb.channel.dao.flow.ExecutionFlow;
import com.yhb.utils.DateUtils;
import lombok.*;
import lombok.extern.log4j.Log4j;
import org.apache.http.util.TextUtils;

import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;

@Data
@Log4j
public class LeShuaFlow {
    private String phone;
    private String sn;
    private int ordertCrash;
    private String productCode;
    private String tradeNo;
    private String merchantsAccount;
    private Date orderTime;
    private int cardType;
    private String referenceNum;
    private String rate;
    private String orderNo;
    private int tradingType;
    private int payType;
    private String terminalNum;
    private int rateD0;
    private String productName;
    private String longitudeAndLatitude;
    private String cardNumber;
    private String coding;



    private String id;
    private String userId;
    private String vipType;
    private BigDecimal commission; // 消费手续费
    private BigDecimal amount;

    public void setOrderTime(String orderTime) {
        if (TextUtils.isEmpty(orderTime)) return;

        try {
            this.orderTime = DateUtils.noobDateFormat.parse(orderTime);
        } catch (Throwable t) {
            log.error("parse time err:" + orderTime, t);
        }
    }

    public void setOrderTime(Date date) {
        this.orderTime = date;
    }

    public void convertAmount() {
        if (this.amount == null) {
            this.amount = BigDecimal.valueOf(ordertCrash).setScale(5, RoundingMode.CEILING).divide(BigDecimal.TEN.multiply(BigDecimal.TEN), RoundingMode.CEILING);
        }
    }
}
